home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 December / Australian PC User - December 2003 (CD2).iso / software / apps / files / dwmx2k4.exe / Disk1 / data1.cab / Configuration_En / ServerModels / Shared / ASPNetShared.js next >
Encoding:
JavaScript  |  2003-09-05  |  7.3 KB  |  294 lines

  1. // Copyright 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. //--------------------------------------------------------------------
  4. // FUNCTION:
  5. //   getColumnValueNode
  6. //
  7. // DESCRIPTION:
  8. //   This function returns a platform specific instance of the
  9. //   ColumnValueNode class.  This function is called by dwscripts,
  10. //   and serves as a factory method.
  11. //
  12. // ARGUMENTS:
  13. //   none
  14. //
  15. // RETURNS:
  16. //   ASPNetColumnValueNode object
  17. //--------------------------------------------------------------------
  18.  
  19. function getColumnValueNode()
  20. {
  21.   return new ASPNetColumnValueNode();
  22. }
  23.  
  24. //--------------------------------------------------------------------
  25. // CLASS:
  26. //   ASPNetColumnValueNode
  27. //
  28. // DESCRIPTION:
  29. //   This class represents the mapping of a database column to a value.
  30. //
  31. // PUBLIC PROPERTIES:
  32. //   None
  33. //
  34. // PUBLIC FUNCTIONS:
  35. //   See the base class in:
  36. //     Configuration/Shared/Common/Scripts/ColumnValueNodeClass.js
  37. //
  38. //--------------------------------------------------------------------
  39.  
  40. ASPNetColumnValueNode.prototype.__proto__ = ColumnValueNode.prototype;
  41. ASPNetColumnValueNode.prototype.initialize = ASPNetColumnValueNode_initialize;
  42. ASPNetColumnValueNode.prototype.setVariableName = ASPNetColumnValueNode_setVariableName;
  43. ASPNetColumnValueNode.prototype.setSubmitAs = ASPNetColumnValueNode_setSubmitAs;
  44. ASPNetColumnValueNode.prototype.getSubmitAs = ASPNetColumnValueNode_getSubmitAs;
  45. ASPNetColumnValueNode.prototype.setDefaultValue = ASPNetColumnValueNode_setDefaultValue;
  46. ASPNetColumnValueNode.prototype.getDefaultValue = ASPNetColumnValueNode_getDefaultValue;
  47. ASPNetColumnValueNode.prototype.setParamType = ASPNetColumnValueNode_setParamType;
  48. ASPNetColumnValueNode.prototype.getParamType = ASPNetColumnValueNode_getParamType;
  49.  
  50. //--------------------------------------------------------------------
  51.  
  52. function ASPNetColumnValueNode()
  53. {
  54.   this.initialize();
  55. }
  56.  
  57. function ASPNetColumnValueNode_initialize()
  58. {
  59.   this.columnName = "";
  60.   this.columnType = "";
  61.   this.isPrimaryKey = false;
  62.   this.varName = "";
  63.   this.runtimeValue = "";
  64.   this.submitAs = "";
  65.   this.paramType = "";
  66.   this.defaultValue = "";
  67. }
  68.  
  69. function ASPNetColumnValueNode_setVariableName(varName)
  70. {
  71.   this.varName = varName;
  72. }
  73.  
  74. function ASPNetColumnValueNode_setSubmitAs(submitAs)
  75. {
  76.   this.submitAs = submitAs;
  77. }
  78.  
  79. function ASPNetColumnValueNode_getSubmitAs()
  80. {
  81.   return this.submitAs;
  82. }
  83.  
  84. function ASPNetColumnValueNode_setDefaultValue(defaultValue)
  85. {
  86.   this.defaultValue = defaultValue;
  87. }
  88.  
  89. function ASPNetColumnValueNode_getDefaultValue()
  90. {
  91.   return this.defaultValue;
  92. }
  93.  
  94. function ASPNetColumnValueNode_setParamType(paramType)
  95. {
  96.   this.paramType = paramType;
  97. }
  98.  
  99. function ASPNetColumnValueNode_getParamType()
  100. {
  101.   return this.paramType;
  102. }
  103.  
  104. //--------------------------------------------------------------------
  105. // FUNCTION:
  106. //   getParameterTypeArray
  107. //
  108. // DESCRIPTION:
  109. //   Get list of available parameter types.
  110. //
  111. // ARGUMENTS:
  112. //   bRemoveEnteredVal - boolean (optional). 'true' if should remove 'Entered Value'
  113. //     as a possible parameter type. Defaults to 'false'.
  114. //
  115. // RETURNS:
  116. //   array of strings - localized list of parameter types.
  117. //--------------------------------------------------------------------
  118.  
  119. function getParameterTypeArray(bRemoveEnteredVal)
  120. {
  121.   // Make a copy of MM.LABEL_ASPNET_Param_Types. We may need to alter it and we
  122.   //   don't want to affect the original array.
  123.  
  124.   var paramTypes = new Array();
  125.  
  126.   for (var i = 0; i < MM.LABEL_ASPNET_Param_Types.length; ++i)
  127.   {
  128.     paramTypes.push(MM.LABEL_ASPNET_Param_Types[i]);
  129.   }
  130.   
  131.   if (bRemoveEnteredVal)
  132.   {
  133.     paramTypes.splice(paramTypes.length - 1, 1);
  134.   }
  135.  
  136.   return paramTypes;
  137. }
  138.  
  139. //--------------------------------------------------------------------
  140. // FUNCTION:
  141. //   getDBColumnTypeAsString
  142. //
  143. // DESCRIPTION:
  144. //   Maps the enumerated number used by the database to represent a type to the
  145. //   corresponding sql type string.
  146. //
  147. // ARGUMENTS:
  148. //   typeNum - enumerated number. Number used by the database to represent
  149. //     the type.
  150. //   databaseType - string. "OleDb" or "SQLServer" for now.
  151. // RETURNS:
  152. //   string - ASP.Net type string. null if typeNum is not found.
  153. //--------------------------------------------------------------------
  154.  
  155. function getDBColumnTypeAsString(typeNum, databaseType)
  156. {
  157.     var a = new Array();
  158.  
  159.     // OleDb types
  160.  
  161.     a['0'] = "Empty";
  162.     a['2'] = "SmallInt";
  163.     a['3'] = "Integer";
  164.     a['4'] = "Single";
  165.     a['5'] = "Double";
  166.     a['6'] = "Currency";
  167.     a['7'] = "Date";
  168.     a['8'] = "BSTR";
  169.     a['9'] = "IDispatch";
  170.     a['10'] = "Error";
  171.     a['11'] = "Boolean";
  172.     a['12'] = "Variant";
  173.     a['13'] = "IUnknown";
  174.     a['14'] = "Decimal";
  175.     a['16'] = "TinyInt";
  176.     a['17'] = "UnsignedTinyInt";
  177.     a['18'] = "UnsignedSmallInt";
  178.     a['19'] = "UnsignedInt";
  179.     a['20'] = "BigInt";
  180.     a['21'] = "UnsignedBigInt";
  181.     a['72'] = "GUID";
  182.     a['128'] = "Binary";
  183.     a['129'] = "VarChar";
  184.     a['130'] = "WChar";
  185.     a['131'] = "Numeric";
  186.     a['132'] = "UserDefined";
  187.     a['133'] = "DBDate";
  188.     a['134'] = "DBTime";
  189.     a['135'] = "DBTimeStamp";
  190.     a['139'] = "VarNumeric";
  191.     a['200'] = "VarChar";
  192.     a['201'] = "LongVarChar";
  193.     a['202'] = "VarWChar";
  194.     a['203'] = "LongVarWChar";
  195.     a['204'] = "VarBinary";
  196.     a['205'] = "LongVarBinary";
  197.     a['900'] = "REF CURSOR";
  198.     a['901'] = "bit";
  199.  
  200.     // Database-specific overrides
  201.  
  202.     if (databaseType.toLowerCase() == "sqlserver")
  203.     {
  204.         a['3'] = "Int";
  205.         a['4'] = "Real";
  206.         a['5'] = "Float";
  207.         a['6'] = "Money";
  208.         a['7'] = "DateTime";
  209.         a['8'] = "BSTR";
  210.         a['11'] = "Bit";
  211.         a['17'] = "SmallInt";
  212.         a['18'] = "SmallInt";
  213.         a['19'] = "Int";
  214.         a['21'] = "BitInt";
  215.         a['130'] = "NChar";
  216.         a['131'] = "Decimal";
  217.         a['133'] = "DateTime";
  218.         a['134'] = "DateTime";
  219.         a['135'] = "DateTime";
  220.         a['139'] = "Decimal";
  221.         a['201'] = "NVarChar";
  222.         a['202'] = "NVarChar";
  223.         a['203'] = "NVarChar";
  224.     }
  225.  
  226.     return (a[typeNum] && (a[typeNum] != "")) ? a[typeNum] : null;
  227. }
  228.  
  229. //--------------------------------------------------------------------
  230.  
  231. function warnIfNoPageNavDisplay(recordsetName, ignoreCase, isAll)
  232. {
  233.     if (!canInsertPageNavDisplay(recordsetName, ignoreCase, isAll))
  234.     {
  235.         dwscripts.informDontShow(dwscripts.sprintf(MM.MSG_WarnAboutPageNavForDataSet, recordsetName),
  236.             "Extensions\\ServerBehaviors\\PageNavigation","SkipPageNavDisplayWarning");
  237.     }
  238. }
  239.  
  240. function canInsertPageNavDisplay(recordsetName, ignoreCase, isAll)
  241. {
  242.     var canInsert = false;
  243.     var dom = dw.getDocumentDOM();
  244.     var dataSetTags = dom.getElementsByTagName("MM:DataSet");
  245.     var rsName = recordsetName;
  246.  
  247.     if (rsName && ignoreCase)
  248.     {
  249.         rsName = rsName.toLowerCase();
  250.     }
  251.  
  252.     for (var j = 0; j < dataSetTags.length; ++j)
  253.     {
  254.         var id = dataSetTags[j].getAttribute("id");
  255.  
  256.         if (!id)
  257.             continue;
  258.             
  259.         if (ignoreCase)
  260.         {
  261.             id = id.toLowerCase();
  262.         }
  263.     
  264.         if ((rsName != null) && (rsName != id))
  265.             continue;
  266.             
  267.         if (!dataSetTags[j].getAttribute("PageSize"))
  268.             continue;
  269.             
  270.         canInsert = true;
  271.         break;
  272.     }
  273.  
  274.     return canInsert;
  275. }
  276.  
  277. function getRecordsetNameWithPageNav()
  278. {
  279.   var retVal = "";
  280.   var dom = dw.getDocumentDOM();
  281.   var dataSetTags = dom.getElementsByTagName("MM:DataSet");
  282.  
  283.   for (var i = 0; i < dataSetTags.length; ++i)
  284.   {
  285.     if (dataSetTags[i].getAttribute("PageSize"))
  286.     {
  287.       retVal = dataSetTags[i].getAttribute("id");
  288.       break;
  289.     }
  290.   }
  291.  
  292.   return retVal;
  293. }
  294.